package primetest.faces;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;


import primetest.dto.MedicineDto;

public class MedicineListModel extends ListDataModel<MedicineDto> implements SelectableDataModel<MedicineDto> {

	public MedicineListModel(List<MedicineDto> bookList){
		super(bookList);
	}

	@Override
	public MedicineDto getRowData(String rowKey) {
		@SuppressWarnings("unchecked")
		List<MedicineDto> bookList = (List<MedicineDto>)getWrappedData();
		for (MedicineDto bookDto : bookList) {
			if(bookDto.getKey().equals(rowKey)){
				return bookDto;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(MedicineDto bookDto) {
		return bookDto.getKey();
	}

}
